package com.exam.controller.exam;

import com.exam.common.Result;
import com.exam.common.SuperController;
import com.exam.pojo.param.ExamIntroductionParam;
import com.exam.service.ExamIntroductionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description  (ExamIntroduction)表控制层
 * @Author Chengke
 * @Date  2023-01-07
 */
@Api(tags = "ExamIntroduction")
@RestController
@RequestMapping("/examIntroduction")
public class ExamIntroductionController extends SuperController {

    @Resource
    private ExamIntroductionService examIntroductionService;


    @ApiOperation("分页查询")
    @PostMapping("/{pageNum}/{pageSize}")
    public Result queryByPage(@RequestBody ExamIntroductionParam examIntroduction,
                              @PathVariable("pageNum") Integer pageNum,
                              @PathVariable("pageSize") Integer pageSize) {
        return success(this.examIntroductionService.queryByPage(examIntroduction, pageNum, pageSize));
    }


    @ApiOperation("通过类型查询")
    @GetMapping("/type")
    public Result queryByType(String typeEnum) {
        return success(this.examIntroductionService.queryByType(typeEnum));
    }


    @ApiOperation("通过主键查询单条数据")
    @GetMapping("/{id}")
    public Result queryById(@PathVariable("id") String id) {
        return success(this.examIntroductionService.queryById(id));
    }


    @ApiOperation("新增数据")
    @PostMapping
    public Result add(@RequestBody ExamIntroductionParam examIntroduction) {
        return success(this.examIntroductionService.insert(examIntroduction));
    }


    @ApiOperation("编辑数据")
    @PutMapping
    public Result edit(@RequestBody ExamIntroductionParam examIntroduction) {
        return success(this.examIntroductionService.update(examIntroduction));
    }


    @ApiOperation("删除数据")
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable("id") String id) {
        return this.examIntroductionService.deleteById(id);
    }

}

